<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String id = request.getParameter("id");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
<html>  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
<title>Test remote Login using JS121</title>  
<script type="text/javascript">  
function prepareLoginForm() {  
    $('myLoginForm').action = casLoginURL; 
	
    $("lt").value = loginTicket; 
    aa= 'http://10.1.6.175:18108/bsm/resource/res-query!view.action?id='+resId;  
    $("service").value = encodeURIComponent (aa);
    $("myLoginForm").submit();
    
}  
var resId ='<%=id%>';
var loginTicket;
var error;
var casLoginURL;
var thisPageURL;

function checkForLoginTicket() {
   var loginTicketProvided = false;  
   var query   = '';  
   casLoginURL = 'http://10.1.6.175:18208/sso-server/login';  
   thisPageURL = 'http://10.1.6.175:18108/bsm/no-login.jsp?resId='+resId; 
   casLoginURL += '&service=' + encodeURIComponent ('http://10.1.6.175:18108/bsm/resource/res-query!view.action?id='+resId);  	
   casLoginURL += '&login-at=' + encodeURIComponent (thisPageURL);
   query= window.location.search;  
   query = query.substr(1);
   var param   = new Array();
    //var value = new Array();  
    var temp    = new Array();  
    param   = query.split ('&');  
    i = 0;
    while (param[i]) {
        temp = param[i].split('=');  
        if (temp[0] == 'lt') {  
            loginTicket = temp[1];  
            loginTicketProvided = true;  
        }  
        if (temp[0] == 'error_message') {  
                error = temp[1];  
            }  
        i++;  
    }  
    if (!loginTicketProvided) {  
        location.href = casLoginURL + '&get-lt=true';  
    }
}
var $ = function(id){ 
    return document.getElementById(id);  
}
checkForLoginTicket();
onload = prepareLoginForm;
</script>  
</head>  
<body>  
<form id="myLoginForm" action="" method="post">  
<input type="hidden" value="admin" name="username" >
<input type="hidden" value="000000" name="password" >
<input type="hidden" name="lt" id="lt" value="">
<input type="hidden" name="_eventId" value="submit" />  
</form>  
</body>  
</html> 